import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path:'/demo',
    component:()=>import('../components/demo.vue')
  },
  {
    path:"/index",
    component:()=>import('../views/index.vue'),
    children:[
      {
        path:'/top',
        component:()=>import('../views/plantingAreaTop.vue')
      },
      {
        path:'/harv',
        component:()=>import('../views/plantingHarvest.vue')
      },
      {
        path:'/total',
        component:()=>import('../views/totalArea.vue')
      },
      {
        path:'/crop',
        component:()=>import('../views/cropArea.vue')
      },
      {
        path:'/map',
        component:()=>import('../views/copCoverage.vue')
      },
      {
        path:'/grop',
        component:()=>import('../views/gropGrow.vue')
      },
      {//二级路由重定向
        path:'',
        redirect:'/top'
      }
    ]
  },
  {//一级路由重定向
    path:'*',
    redirect:"/index"
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
